package com.address.book;

import com.smzh.common.AnnotatedPojoUtil;

public class TestAnnontationBook {
	public static void main(String[] args) throws Exception {
		AddressBook addressBook = new AddressBook();

		Person person = new Person();
		person.setId(1);
		person.setCategory("acquaintance");
		person.setName("Gonzo");
		person.addEmail("business", "gonzo@muppets.com");

		Address address = new Address();
		address.setType("home");
		address.setStreet("123 Maine Ave.");
		address.setCity("Las Vegas");
		address.setState("NV");
		address.setZip("01234");
		address.setCountry("USA");
		person.addAddress(address);

		address = new Address();
		address.setType("business");
		address.setStreet("234 Maple Dr.");
		address.setCity("Los Angeles");
		address.setState("CA");
		address.setZip("98765");
		address.setCountry("USA");
		person.addAddress(address);

		addressBook.addPerson(person);

		person = new Person();
		person.setId(2);
		person.setCategory("rolemodel");
		person.setName("Kermit");
		person.addEmail("business", "kermit@muppets.com");
		person.addEmail("home", "kermie@acme.com");

		address = new Address();
		address.setType("business");
		address.setStreet("987 Brown Rd");
		address.setCity("Las Cruces");
		address.setState("NM");
		address.setZip("75321");
		address.setCountry("USA");
		person.addAddress(address);

		addressBook.addPerson(person);
		
		AddressBook addressBook2=(AddressBook) AnnotatedPojoUtil.xmlParseToObject(AddressBook.class,AddressBook.class.getSimpleName() + ".xml");

		System.out.println(addressBook2.getPerson(0).getName());
	}
}
